//
//  STMConsultTableViewCell.m
//  StoreManagement
//
//  Created by centling on 16/5/21.
//  Copyright © 2016年 alfred. All rights reserved.
//

#import "STMConsultTableViewCell.h"

@implementation STMConsultTableViewCell

- (void)awakeFromNib {
    [self.replyButton addTarget:self action:@selector(replyButtonClick) forControlEvents:UIControlEventTouchUpInside];
}

- (void)setCellData:(STMConsultList *)cellData {
    self.storeId = cellData.consult.store_id;
    self.consultId = cellData.consult.consult_id;
    self.consultContentLabel.text = cellData.consult.consult_content;
    [self.goodsImageView sd_setImageWithURL:[NSURL URLWithString:cellData.goods_info.goods_image] placeholderImage:nil];
    self.goodsNameLabel.text = cellData.goods_info.goods_name;
    self.goodsPriceLabel.text = cellData.goods_info.goods_price;
    self.goodsFreightLabel.text = cellData.goods_info.goods_freight;
    self.consultReplyLabel.text = [NSString stringWithFormat:@"回复：%@",cellData.consult.consult_reply];
    if ([self.consultType isEqualToString:@"to_reply"]) {
        self.consultReplyLabel.hidden = YES;
        self.dateLabelToTopConstraint.constant = -16;
        self.dateLabel.text = [GlobalUtil setUpTime:cellData.consult.consult_addtime];
    } else {
        self.replyButton.hidden = YES;
        self.dateLabel.text = [GlobalUtil setUpTime:cellData.consult.consult_reply_time];
    }
}


- (void)replyButtonClick {
    if (_consultCellBlock) {
        _consultCellBlock(self.storeId, self.consultId);
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
